//package com.happly.happlycloud.controller.Totur;
//
//import com.github.pagehelper.PageInfo;
//import com.happly.happlycloud.common.ResponseCode;
//import com.happly.happlycloud.common.ServerResponse;
//import com.happly.happlycloud.pojo.User;
//import com.happly.happlycloud.service.IOrderService;
//import com.happly.happlycloud.service.IUserService;
//import com.happly.happlycloud.util.CookieUtil;
//import com.happly.happlycloud.util.JsonUtil;
//import com.happly.happlycloud.util.RedisShardedPoolUtil;
//import com.happly.happlycloud.vo.OrderVo;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import org.apache.commons.lang.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.RestController;
//
//import javax.servlet.http.HttpServletRequest;
//
//@RequestMapping("/tutor/order")
//@RestController
//@Api("教员订单")
//public class OrderToturController {
//
//    @Autowired
//    private IUserService iUserService;
//    @Autowired
//    private IOrderService iOrderService;
//
//    @RequestMapping("list.do")
//    @ApiOperation("添加")
//    public ServerResponse<PageInfo> orderList(HttpServletRequest httpServletRequest, @RequestParam(value = "pageNum",defaultValue = "1") int pageNum,
//                                              @RequestParam(value = "pageSize",defaultValue = "10")int pageSize){
//
//
//        String loginToken = CookieUtil.readLoginToken(httpServletRequest);
//        if(StringUtils.isEmpty(loginToken)){
//            return ServerResponse.createByErrorMessage("教员未登录,无法获取当前用户的信息");
//        }
//        String userJsonStr = RedisShardedPoolUtil.get(loginToken);
//        User currentUser = JsonUtil.stringToObj(userJsonStr,User.class);
//        if(currentUser == null){
//            return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),"用户未登录,请登录教员");
//
//        }
//        if(iUserService.checkToturRole(currentUser).isSuccess()){
//            //填充我们增加产品的业务逻辑
//            return iOrderService.tutorList(pageNum,pageSize,currentUser.getId());
//        }else{
//            return ServerResponse.createByErrorMessage("无权限操作");
//        }
//    }
//
//    @RequestMapping("detail.do")
//    @ApiOperation("添加")
//    public ServerResponse<OrderVo> orderDetail(HttpServletRequest httpServletRequest, Long orderNo){
//
//        String loginToken = CookieUtil.readLoginToken(httpServletRequest);
//        if(StringUtils.isEmpty(loginToken)){
//            return ServerResponse.createByErrorMessage("教员未登录,无法获取当前用户的信息");
//        }
//        String userJsonStr = RedisShardedPoolUtil.get(loginToken);
//        User currentUser = JsonUtil.stringToObj(userJsonStr,User.class);
//        if(currentUser == null){
//            return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),"用户未登录,请登录管理员");
//
//        }
//        if(iUserService.checkToturRole(currentUser).isSuccess()){
//            //填充我们增加产品的业务逻辑
//
//            return iOrderService.manageDetail(orderNo);
//        }else{
//            return ServerResponse.createByErrorMessage("无权限操作");
//        }
//    }
//
//
//
//    @RequestMapping("search.do")
//    @ApiOperation("添加")
//    public ServerResponse<PageInfo> orderSearch(HttpServletRequest httpServletRequest, Long orderNo,@RequestParam(value = "pageNum",defaultValue = "1") int pageNum,
//                                               @RequestParam(value = "pageSize",defaultValue = "10")int pageSize){
//        String loginToken = CookieUtil.readLoginToken(httpServletRequest);
//        if(StringUtils.isEmpty(loginToken)){
//            return ServerResponse.createByErrorMessage("教员未登录,无法获取当前用户的信息");
//        }
//        String userJsonStr = RedisShardedPoolUtil.get(loginToken);
//        User currentUser = JsonUtil.stringToObj(userJsonStr,User.class);
//        if(currentUser == null){
//            return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),"用户未登录,请登录管理员");
//
//        }
//        if(iUserService.checkToturRole(currentUser).isSuccess()){
//            //填充我们增加产品的业务逻辑
//            return iOrderService.manageSearch(orderNo,pageNum,pageSize);
//        }else{
//            return ServerResponse.createByErrorMessage("无权限操作");
//        }
//    }
//
//
//
//    @RequestMapping("send_goods.do")
//    @ApiOperation("添加")
//    public ServerResponse<String> orderSendGoods(HttpServletRequest httpServletRequest, Long orderNo){
//
//        String loginToken = CookieUtil.readLoginToken(httpServletRequest);
//        if(StringUtils.isEmpty(loginToken)){
//            return ServerResponse.createByErrorMessage("教员未登录,无法获取当前用户的信息");
//        }
//        String userJsonStr = RedisShardedPoolUtil.get(loginToken);
//        User currentUser = JsonUtil.stringToObj(userJsonStr,User.class);
//        if(currentUser == null){
//            return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),"用户未登录,请登录教员");
//
//        }
//        if(iUserService.checkToturRole(currentUser).isSuccess()){
//            //填充我们增加产品的业务逻辑
//            return iOrderService.manageSendGoods(orderNo);
//        }else{
//            return ServerResponse.createByErrorMessage("无权限操作");
//        }
//    }
//
//}
